﻿/*
 * User: artem
 * Date: 05/09/2011
 * Time: 12:19
 * 
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Media;
using System.IO;
using System.Windows.Resources;

namespace Demon
{
	/// <summary>
	/// Interaction logic for NotificationDialog.xaml
	/// </summary>
	public partial class NotificationDialog : Window
	{
        private const string path = @"Resource/Images/{0}.png";

        public string TitleEvent
        { set { this.txtTitle.Text = value; } }

        public string DescriptionEvent
        { set { this.txtDescription.Text = value; } }

        public string DateEvent
        { set { this.txtDate.Text = value; } }

        public string Type
        {
            set
            {
                try
                {
                    this.imgType.Source = 
                        new BitmapImage(new Uri(String.Format(path,
                                                              value),
                                                UriKind.Relative));
                }
                catch
                {   }
            }
        }

        public bool Periodic
        {
            set
            {
                const string yes = @"Periodic";
                const string no = @"NonePeriodic";

                try
                {
                    this.imgPeriodic.Source =
                        new BitmapImage(new Uri(String.Format(path,
                                                              (value ? yes : no)),
                                                UriKind.Relative));
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
        }

		public NotificationDialog()
		{
			InitializeComponent();
		}

        private void btnClose_Click(object sender, RoutedEventArgs e)
        { this.Close(); }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            const string sound_file_location = @"Resource/Sounds/Notify.wav";
            
            try
            {
                StreamResourceInfo ri = 
                    Application.GetResourceStream(new Uri(sound_file_location, 
                                                          UriKind.Relative));

                SoundPlayer player = new SoundPlayer();
                player.Stream = ri.Stream;
                player.Load();
                player.Play();
            }
            catch
            {   }
        }
	}
}